package com.hsteach.web.controller.activity;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.hsteach.common.core.controller.BaseController;
import com.hsteach.common.core.domain.AjaxResult;
import com.hsteach.common.core.page.TableDataInfo;
import com.hsteach.common.utils.poi.ExcelUtil;
import com.hsteach.dao.domain.activity.ActivityClass;
import com.hsteach.service.activity.ActivityClassService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 活动发布班级Controller
 * 弃用
 * @author fanxquer
 * @date 2023-07-10
 */
@RestController
@RequestMapping("/system/class")
@Deprecated
public class ActivityClassController extends BaseController
{
    @Autowired
    private ActivityClassService activityClassService;

    /**
     * 查询活动发布班级列表
     */
    @PreAuthorize("@ss.hasPermi('system:class:list')")
    @GetMapping("/list")
    public TableDataInfo list(ActivityClass activityClass)
    {
        startPage();
        List<ActivityClass> list = activityClassService.selectTbActivityClassList(activityClass);
        return getDataTable(list);
    }

    /**
     * 导出活动发布班级列表
     */
    @PreAuthorize("@ss.hasPermi('system:class:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, ActivityClass activityClass)
    {
        List<ActivityClass> list = activityClassService.selectTbActivityClassList(activityClass);
        ExcelUtil<ActivityClass> util = new ExcelUtil<ActivityClass>(ActivityClass.class);
        util.exportExcel(response, list, "活动发布班级数据");
    }

    /**
     * 获取活动发布班级详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:class:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(activityClassService.selectTbActivityClassById(id));
    }

    /**
     * 新增活动发布班级
     */
    @PreAuthorize("@ss.hasPermi('system:class:add')")
    @PostMapping
    public AjaxResult add(@RequestBody ActivityClass activityClass)
    {
        return toAjax(activityClassService.insertTbActivityClass(activityClass));
    }

    /**
     * 修改活动发布班级
     */
    @PreAuthorize("@ss.hasPermi('system:class:edit')")
    @PutMapping
    public AjaxResult edit(@RequestBody ActivityClass activityClass)
    {
        return toAjax(activityClassService.updateTbActivityClass(activityClass));
    }

    /**
     * 删除活动发布班级
     */
    @PreAuthorize("@ss.hasPermi('system:class:remove')")
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(activityClassService.deleteTbActivityClassByIds(ids));
    }
}
